package com.tian.clothing.widget;

import com.tian.clothing.R;
import com.tian.clothing.widget.base.BaseCustomView;
import com.tian.clothing.widget.base.MyViewStyle;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.Button;
import android.widget.TextView;

/**
 * @ClassName: TitleBar
 * @Description: 界面自定义TitleBar
 * @author: dreamfutureba@gmail.com
 * @date: 2013年11月21日 下午3:38:59
 */
public class TitleBar extends BaseCustomView implements MyViewStyle{

	// 通用的titlebar
		public TextView titlebar_tv_center;// 中间的文本
		public Button titlebar_btn_left;// 左边的按钮
		public Button titlebar_btn_right;

		public interface TITLEBAR_STYLE {
			int ONE_TITLE_STYLE = 1;// 2个返回按钮和一个Title的TitleBar.
			int OTHER_TITLE_STYLE = 2;// 扩展TitleBar样式
		}
		
		public TitleBar(Context context) {
			super(context);
		}

		public TitleBar(Context context, AttributeSet attrs) {
			super(context, attrs);
		}

		@Override
		protected void inflateView() {
			// TODO Auto-generated method stub
		}

		@Override
		protected void registerViewEvents() {
			// TODO Auto-generated method stub
		}

		@Override
		public void changeStyle(int style) {
			getViewByInflater(style);
		}
		
		/**
		 * 更改TitleBar的显示样式，
		 */
		private void getViewByInflater(int style) {
			switch (style) {
			case TITLEBAR_STYLE.ONE_TITLE_STYLE:
				buildOneTitleAndBtn_Style();
				break;
			case TITLEBAR_STYLE.OTHER_TITLE_STYLE:
				
				break;
			}
		}
		
		/**
		 * 构建2个按钮和1个标题的TitleBar
		 */
		private void buildOneTitleAndBtn_Style(){
			setContentView(R.layout.view_title_bar);
			titlebar_tv_center=(TextView) findViewById(R.id.titlebar_tv_center);
			titlebar_btn_left=(Button) findViewById(R.id.titlebar_btn_left);
			titlebar_btn_right=(Button) findViewById(R.id.titlebar_btn_right);
		}

}
